<template>
  <div class="caseComp">
    <div class="caseCompTitle">编辑查实情况</div>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
    >
      <el-row>
        <el-col :span="12">
          <el-form-item label="查实结果：" prop="isTrue">
            <el-select v-model="ruleForm.isTrue" class="caseCompTitleInput">
              <el-option value="0" label="非欠薪问题"></el-option>
              <el-option value="1" label="欠薪问题"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="回复专线日期：">
            <el-date-picker
              type="datetime"
              class="caseCompTitleInput"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择日期"
              v-model="ruleForm.revertDate"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="备注：">
        <el-input
          type="textarea"
          :line="3"
          v-model="ruleForm.checkRemark"
          placeholder="请输入"
        ></el-input>
      </el-form-item>
    </el-form>
    <div class="caseCompBtn">
      <el-button type="primary" class="commonBut saveBtn" @click="save"
        >保存</el-button
      >
      <el-button type="default" class="commonBut" @click="finish"
        >取消</el-button
      >
    </div>
  </div>
</template>
<script>
export default {
  name: 'caseDepartment',
  props: {
    childData: {
      type: Object,
      required: true,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      ruleForm: {
        id: '',
        isTrue: '',
        revertDate: '',
        checkRemark: '',
      },
      rules: {
        isTrue: [
          { required: true, message: '请选择查实结果', trigger: 'change' },
        ],
      },
    }
  },
  mounted() {
    const { id, isTrue, revertDate, checkRemark } = this.childData
    this.ruleForm = {
      id,
      isTrue: isTrue === 'null' ? '' : isTrue,
      revertDate,
      checkRemark,
    }
  },
  methods: {
    save() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.isLoading = true
          const { id, isTrue, revertDate, checkRemark } = this.ruleForm
          let params = { id, isTrue, revertDate, checkRemark }
          this.axios.post('api-r/rbp/modifyCheckStatus', params).then((res) => {
            if (!res.data.hasError) {
              this.$message({
                type: 'success',
                message: res.data.msg,
              })
              this.isLoading = false
              this.finish(1)
            } else {
              this.$message({
                type: 'warning',
                message: res.data.errorMsg,
              })
              this.isLoading = false
            }
          })
        } else {
          return false
        }
      })
    },
    finish(index) {
      this.$emit('callback', { success: index == 1 ? true : false })
    },
  },
}
</script>
<style lang="less" scoped>
.caseComp {
  border: 1px solid #dcdfe6;
  background-color: #f8f9fb;
  padding: 15px;
  &Title {
    color: #009588;
    font-size: 14px;
    line-height: 30px;
    margin-bottom: 12px;
  }
  &List {
    line-height: 36px;
    height: 36px;
    font-size: 14px;
    color: #444;
    margin-bottom: 12px;
    &Title {
      display: inline-block;
      width: 85px;
      text-align: right;
    }
    &Input {
      width: calc(100% - 95px);
    }
    .input {
      width: calc(100% - 170px);
    }
  }
  &Btn {
    text-align: center;
    margin: 24px 0 10px;
    .el-button {
      width: 120px;
    }
  }
  /deep/ .el-radio__input.is-checked + .el-radio__label {
    color: #009588 !important;
  }
  /deep/.el-radio__input.is-checked .el-radio__inner {
    background: #009588 !important;
    border-color: #009588 !important;
  }
}
.caseCompTitleInput {
  width: calc(100% - 20px);
}
</style>
